Kameleon-Plus  0.3.2
Public Member Functions | Protected Member Functions | List of all members
ccmc::CDFFileReader Class Reference

#include <CDFFileReader.h>

Inheritance diagram for ccmc::CDFFileReader:
Inheritance graph
[legend]
Collaboration diagram for ccmc::CDFFileReader:
Collaboration graph
[legend]

Public Member Functions

 CDFFileReader ()
 
std::vector< float > * getVariable (const std::string &variable)
 Returns a pointer to a std::vector<float> containing the values of the selected variable.
 
std::vector< float > * getVariable (long variableID)
 
std::vector< float > * getVariable (const std::string &variable, long startIndex, long count)
 
std::vector< float > * getVariable (long variableID, long startIndex, long count)
 
float getVariableAtIndex (const std::string &variable, long index)
 Returns a value in the flat array of the variable and index requested.
 
float getVariableAtIndex (long variable_id, long index)
 
std::vector< int > * getVariableInt (const std::string &variable)
 
int getVariableIntAtIndex (const std::string &variable, long index)
 Returns a value in the flat array of the variable and index requested.
 
int getNumberOfGlobalAttributes ()
 
int getNumberOfVariables ()
 
int getNumberOfVariableAttributes ()
 
long getNumberOfRecords (const std::string &variable)
 
long getNumberOfRecords (long variable_id)
 
long getVariableID (const std::string &variable)
 
std::string getVariableName (long variable_id)
 
Attribute getGlobalAttribute (long i)
 
std::string getGlobalAttributeName (long attribute_id)
 
std::string getVariableAttributeName (long attribute_id)
 
Attribute getGlobalAttribute (const std::string &attribute)
 
long getGlobalAttributeID (const std::string &attribute)
 
Attribute getVariableAttribute (const std::string &variable, const std::string &attribute)
 
std::vector< std::string > getVariableAttributeNames ()
 
bool doesAttributeExist (const std::string &attribute)
 
bool doesVariableExist (const std::string &variable)
 
bool doesAttributeExist (long attribute)
 
bool doesVariableExist (long variable)
 
const std::string & getCurrentFilename ()
 
virtual ~CDFFileReader ()
 
- Public Member Functions inherited from ccmc::FileReader
 FileReader ()
 
long open (const std::string &filename, bool readonly=true)
 
void addVariableName (const std::string &variable, long id)
 
long close ()
 
virtual ~FileReader ()
 

Protected Member Functions

long closeFile ()
 
long openFile (const std::string &filename, bool readonly=true)
 
void initializeGlobalAttributes ()
 
void initializeVariableAttributes ()
 
void initializeVariableIDs ()
 
void initializeVariableNames ()
 
- Protected Member Functions inherited from ccmc::FileReader
void initializeGlobalAttributes ()
 
void initializeVariableAttributes ()
 

Additional Inherited Members

- Static Public Attributes inherited from ccmc::FileReader
static const long OK = 0L
 
static const long OPEN_ERROR = -1L
 
static const long FILE_DOES_NOT_EXIST = -2L
 
static const long VARIABLE_DOES_NOT_EXIST = -3L
 
static const long ATTRIBUTE_DOES_NOT_EXIST = -4L
 
static const long LOAD_FAILED = -5L
 
static const long UNABLE_TO_ALLOCATE_MEMORY = -6L
 
static const long VARIABLE_NOT_IN_MEMORY = -7L
 
static const long MODEL_NOT_SUPPORTED = -8L
 
static const long NOT_A_VALID_KAMELEON_FILE = -9L
 
- Protected Attributes inherited from ccmc::FileReader
std::string current_filename
 
int numGAttributes
 
int numVAttributes
 
boost::unordered_map
< std::string, long > 
variableIDs
 
boost::unordered_map< long,
std::string > 
variableNames
 
boost::unordered_map
< std::string, Attribute
gAttributes
 
boost::unordered_map< long,
Attribute
gAttributeByID
 
boost::unordered_map
< std::string,
boost::unordered_map
< std::string, Attribute > > 
vAttributes
 

Constructor & Destructor Documentation

ccmc::CDFFileReader::CDFFileReader ( )

Default constructor. Does nothing.

ccmc::CDFFileReader::~CDFFileReader ( )
virtual

Destructor

Member Function Documentation

long ccmc::CDFFileReader::closeFile ( )
protectedvirtual

Closes the currently selected file. Call this from the close() method.

Returns
Status of close operation.

Implements ccmc::FileReader.

bool ccmc::CDFFileReader::doesAttributeExist ( const std::string &  attribute)
virtual
Parameters
attribute
Returns

Implements ccmc::FileReader.

bool ccmc::CDFFileReader::doesAttributeExist ( long  attribute)
Parameters
attribute
Returns
bool ccmc::CDFFileReader::doesVariableExist ( const std::string &  variable)
virtual
Parameters
variable
Returns

Implements ccmc::FileReader.

bool ccmc::CDFFileReader::doesVariableExist ( long  variable)
Parameters
variable
Returns
const std::string & ccmc::CDFFileReader::getCurrentFilename ( )
virtual

Returns the current filename.

Returns
The current filename.

Implements ccmc::FileReader.

Attribute ccmc::CDFFileReader::getGlobalAttribute ( long  i)
virtual
Parameters
iThe attribute number
Returns

Implements ccmc::FileReader.

Here is the call graph for this function:

Attribute ccmc::CDFFileReader::getGlobalAttribute ( const std::string &  attribute)
virtual
Parameters
attribute
Returns

Implements ccmc::FileReader.

Here is the call graph for this function:

long ccmc::CDFFileReader::getGlobalAttributeID ( const std::string &  attribute)
virtual
Parameters
attribute
Returns

Implements ccmc::FileReader.

std::string ccmc::CDFFileReader::getGlobalAttributeName ( long  attribute_id)
virtual
Parameters
attribute_id
Returns

Implements ccmc::FileReader.

int ccmc::CDFFileReader::getNumberOfGlobalAttributes ( )
virtual

TODO Retrieves the number of global attributes in the selected file. This is useful for iterating over all available global attributes.

Returns
The number of global attributes stored in the selected file.

Implements ccmc::FileReader.

long ccmc::CDFFileReader::getNumberOfRecords ( const std::string &  variable)
virtual
Parameters
variable
Returns

Implements ccmc::FileReader.

long ccmc::CDFFileReader::getNumberOfRecords ( long  variable_id)
virtual
Parameters
variable_id
Returns

Implements ccmc::FileReader.

int ccmc::CDFFileReader::getNumberOfVariableAttributes ( )
virtual

Gets the number of variable attributes.

Returns
The number of variable attributes in the opened file.

Implements ccmc::FileReader.

int ccmc::CDFFileReader::getNumberOfVariables ( )
virtual
Returns

Implements ccmc::FileReader.

std::vector< float > * ccmc::CDFFileReader::getVariable ( const std::string &  variable)
virtual

Returns a pointer to a std::vector<float> containing the values of the selected variable.

This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Parameters
variable
Returns
std::vector<float> containing the values of the selected variable.

Implements ccmc::FileReader.

Here is the call graph for this function:

std::vector< float > * ccmc::CDFFileReader::getVariable ( long  variable)
virtual

Returns a pointer to a std::vector<float> containing the values of the selected variable stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Parameters
variable
Returns
std::vector<float> containing the values of the selected variable.

Implements ccmc::FileReader.

Here is the call graph for this function:

std::vector< float > * ccmc::CDFFileReader::getVariable ( const std::string &  variable,
long  startIndex,
long  count 
)
virtual

Returns a pointer to a std::vector<float> containing the values of the selected variable in the range specified by the startIndex and count (the number of records to read) stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Parameters
variable
startIndex
count
Returns
std::vector<float> containing the values of the selected variable.

Implements ccmc::FileReader.

Here is the call graph for this function:

std::vector< float > * ccmc::CDFFileReader::getVariable ( long  variable,
long  startIndex,
long  count 
)
virtual

Returns a pointer to a std::vector<float> containing the values of the selected variable in the range specified by the startIndex and count (the number of records to read) stored in the selected file. This allocates a new std::vector<float> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Parameters
variableID
startIndex
count
Returns
std::vector<float> containing the values of the selected variable.

Implements ccmc::FileReader.

Here is the call graph for this function:

float ccmc::CDFFileReader::getVariableAtIndex ( const std::string &  variable,
long  index 
)
virtual

Returns a value in the flat array of the variable and index requested.

Use this method on variables that have a type of float

Parameters
variableThe variable in the file
indexThe index in the variable's array in the file
Returns
float of the value in the array.

Implements ccmc::FileReader.

float ccmc::CDFFileReader::getVariableAtIndex ( long  variableNum,
long  index 
)
virtual
Parameters
variableNum
index
Returns

Implements ccmc::FileReader.

Attribute ccmc::CDFFileReader::getVariableAttribute ( const std::string &  variable,
const std::string &  vattribute 
)
virtual
Parameters
variable
vattribute
Returns

Implements ccmc::FileReader.

Here is the call graph for this function:

std::string ccmc::CDFFileReader::getVariableAttributeName ( long  attribute_id)
virtual
Parameters
attribute_id
Returns
String representing the name of the attribute specified by attribute_id

Implements ccmc::FileReader.

std::vector< std::string > ccmc::CDFFileReader::getVariableAttributeNames ( )
virtual
Returns

Implements ccmc::FileReader.

long ccmc::CDFFileReader::getVariableID ( const std::string &  variable)
virtual

Returns the variable ID as a long. Using the variable ID wherever possible is significantly faster than the equivalent methods accepting the variable string.

Returns
Status of the file operation.

Implements ccmc::FileReader.

std::vector< int > * ccmc::CDFFileReader::getVariableInt ( const std::string &  variable)
virtual

This allocates a new std::vector<int> pointer. Make sure you delete the contents when you done using it, or you will have a memory leak.

Parameters
variable
Returns
vector<int> containing the integer values of the variable

Implements ccmc::FileReader.

Here is the call graph for this function:

int ccmc::CDFFileReader::getVariableIntAtIndex ( const std::string &  variable,
long  index 
)
virtual

Returns a value in the flat array of the variable and index requested.

Use this method on variables that have a type of int

Parameters
variableThe variable in the file
indexThe index in the variable's array in the file
Returns
int of the value in the array.

Implements ccmc::FileReader.

std::string ccmc::CDFFileReader::getVariableName ( long  variable_id)
virtual

Returns the string representation of the variable referred to by variable_id

Returns
String representation of the variable.

Implements ccmc::FileReader.

void ccmc::CDFFileReader::initializeGlobalAttributes ( )
protected
void ccmc::CDFFileReader::initializeVariableAttributes ( )
protected
void ccmc::CDFFileReader::initializeVariableIDs ( )
protectedvirtual

Helper method to initialize a map containing variable IDs. This solves some issues with threaded operations on CDF files.

Implements ccmc::FileReader.

void ccmc::CDFFileReader::initializeVariableNames ( )
protectedvirtual

Helper method to initialize a variable names map. This solves some issues with threaded operations on CDF files.

Implements ccmc::FileReader.

long ccmc::CDFFileReader::openFile ( const std::string &  filename,
bool  readonly = true 
)
protectedvirtual

Opens a new file. If the previous file has been opened successfuly, and has the same filename as the requested filename, nothing will be done.

Parameters
filename
Returns
The status of the open call. This method should be called from open().

Implements ccmc::FileReader.

Here is the call graph for this function:


The documentation for this class was generated from the following files: